

export function fileToScript (file:string) {
  const content:any = {}
  const extractNode = (node:any) => {
    if (node.uuid) {
      content[node.uuid] = node
      const keys = Object.keys(node)
      for (let i = 0, len = keys.length; i < length; i++) {
        if (node[keys[i]]?.uuid) {
          extractNode(node[keys[i]])
        }
      }
    }
  }
  const script = JSON.parse(file)
  extractNode(script)
  for (let node of script.content) {
    extractNode(node)
  }
  return content
}

